package com.zyp.boot05.mapper;

import com.zyp.boot05.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Insert("INSERT INTO user (id,username,password,nickname) VALUES (NULL,#{username},#{password},#{nickname})")
    int insert(User user);

    // 返回值为对象时，会把查询到数据自动封装到对象同名属性中
    @Select("SELECT password FROM user WHERE username=#{username}")
    User selectByUsername(String username);

    @Delete("DELETE FROM user WHERE id=#{id}")
    int deleteById(User user);

    @Update("UPDATE user SET username=#{username},password=#{password},nickname=#{nickname} WHERE id=#{id}")
    int update(int id);
}
